# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: jshin

from coin.strategy.executor.util.last_action_timestamp import (LastActionTimestamp)


class LastFillTimestamp(object):
  def __init__(self, config):
    self._config = config
    self._ts = LastActionTimestamp()

  @property
  def config(self):
    return self._config

  @property
  def num_fills(self):
    return self._ts.num_actions

  @property
  def num_sell_fills(self):
    return self._ts.num_sell_actions

  @property
  def num_buy_fills(self):
    return self._ts.num_buy_actions

  def _within_sell_fill_cooldown_period(self, timestamp):
    return self._ts.within_sell_action_period(self.config.fill_cooldown_period, timestamp)

  def _within_buy_fill_cooldown_period(self, timestamp):
    return self._ts.within_buy_action_period(self.config.fill_cooldown_period, timestamp)

  def set_last_sell_fill(self, timestamp):
    return self._ts.set_last_sell_action(timestamp)

  def set_last_buy_fill(self, timestamp):
    return self._ts.set_last_buy_action(timestamp)
